@include('public.head')
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
            <div class="ibox-tools top_bottom">
                <a href="javascript:void(0)" url="/add_banner" class="btn btn-primary edit">添加</a>
            </div>
            <br />
            <br />
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>banner图片</th>    
                            <th>跳转路径</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    @forelse ($banner as $probability)
                        <tr>
                            <td><img src="{{asset($probability->image)}}" width='150' height='150'></td>
                            <td>{{$probability->url}}</td>
                            <td>
                                <a href="javascript:void(0)" url="/edit_banner/{{$probability->id}}" class="btn btn-primary edit">修改</a>
                                <a href="javascript:void(0)" href_value="/del_banner/{{$probability->id}}" class="btn btn-primary del">删除</a>
                            </td>
                        </tr>
                    @empty
                    @endforelse
                    </tbody>
                </table>
                {{ $banner->links() }}
            </div>
            <script type="text/javascript">
            $(".del").click(function(){
                var url = $(this).attr('href_value');
                var index = layer.confirm('是否确认删除？', {
                  btn: ['是','否'] //按钮
                },function(){
                    $.ajax({
                        url:url,    //请求的url地址
                        dataType:"json",   //返回格式为json
                        processData: false,
                        contentType: false,   
                        type:"GET",   //请求方式
                        success:function(req){
                            //请求成功时处理
                            if(req.status == 0){
                                layer.msg(req.message);
                                return false;
                            }
                               
                            layer.msg('操作成功！');
                            setTimeout(function(){
                                 window.location.href = "/banner";
                            },1000); 
                        }
                    });
                },function(){
                    layer.close(index);
                });
            });
            </script>
        </div>
    </div>
</body>

</html>
